import { Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Flavor } from './flavor.entity';

@Entity() // 默认sql table === 'coffee' 可以传一个表名进去
export class Coffee {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  brand: string;

  @Column({default: 0})
  recommendations: number;

  @JoinTable()
  @ManyToMany(
    type => Flavor,
    (flavor) => flavor.coffees,
    {
      cascade: true,
    }
  )
  flavors: Flavor[];
}
